package com.zhijian.medical.controller;

import com.zhijian.medical.entity.dto.PersonDto;
import com.zhijian.medical.entity.po.RoutineSampleArchive;
import com.zhijian.medical.entity.vo.request.RoutineSampleArchiveSearchVo;
import com.zhijian.medical.entity.vo.response.RoutineSampleArchiveVo;
import com.zhijian.medical.holder.CurrentUserHolder;
import com.zhijian.medical.service.RoutineSampleArchiveService;
import com.zhijian.response.annotation.Response;
import com.zhijian.util.page.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

@Slf4j
@Controller
@Api(tags = "常规病理-归档")
public class RoutineSampleArchiveController {

    @Autowired
    RoutineSampleArchiveService routineSampleArchiveService;

    /**
     * 归档切片列表查询
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/routine/sample/archive/qp/page")
    @ApiOperation("常规病理-切片归档列表")
    public Page<RoutineSampleArchiveVo> archiveQpList(@RequestBody RoutineSampleArchiveSearchVo param) {
        log.info("{} - {}| insert info", this.getClass().getSimpleName(), param);
        param.setArchiveType(RoutineSampleArchiveService.ArchiveType.QP.getCode());
        return routineSampleArchiveService.selectPageList(param);
    }

    @Response
    @PostMapping("/routine/sample/archive/lk/page")
    @ApiOperation("常规病理-蜡块归档列表")
    public Page<RoutineSampleArchiveVo> archiveLkList(@RequestBody RoutineSampleArchiveSearchVo param) {
        log.info("{} - {}| insert info", this.getClass().getSimpleName(), param);
        param.setArchiveType(RoutineSampleArchiveService.ArchiveType.LK.getCode());
        return routineSampleArchiveService.selectPageList(param);
    }

    /**
     * 切片归档数据
     *
     * @param routineSampleArchive
     * @return
     */
    @Response
    @PostMapping("/routine/sample/archive/qp")
    @ApiOperation("常规病理-新增切片归档列表")
    public void addQpArchive(@RequestBody RoutineSampleArchive routineSampleArchive) {
        log.info("{} - {}| insert info", this.getClass().getSimpleName(), routineSampleArchive);
        PersonDto personDto = CurrentUserHolder.getUser();
        routineSampleArchive.setArchiverId(personDto.getId());
        routineSampleArchive.setArchiverName(personDto.getName());
        routineSampleArchive.setArchiveType(RoutineSampleArchiveService.ArchiveType.QP.getCode());
        routineSampleArchive.setState(0);
        routineSampleArchiveService.addRoutineSampleArchive(routineSampleArchive);
    }

    /**
     * 蜡块归档记录
     * @param routineSampleArchive
     * @return
     */
    @Response
    @PostMapping("/routine/sample/archive/lk")
    @ApiOperation("常规病理-新增蜡块归档列表")
    public void addLkArchive(@RequestBody RoutineSampleArchive routineSampleArchive) {
        log.info("{} - {}| insert info", this.getClass().getSimpleName(), routineSampleArchive);
        PersonDto personDto = CurrentUserHolder.getUser();
        routineSampleArchive.setArchiverId(personDto.getId());
        routineSampleArchive.setArchiverName(personDto.getName());
        routineSampleArchive.setArchiveType(RoutineSampleArchiveService.ArchiveType.LK.getCode());
        routineSampleArchive.setState(0);
        routineSampleArchiveService.addRoutineSampleArchive(routineSampleArchive);
    }
}
